Page({
  data: {
    describe: '',
    source: [],
    block:true, // 点击上传默认是不是块元素
    xBlockNum:-1,//初始红叉是不是块元素
    imgUrls: getApp().globalData.imgUrl
  },
  onLoad: function(options) {

  },

  onShow: function() {

  },
  showRedCha(e){
    console.log(e.currentTarget.dataset.index)
    this.setData({
      xBlockNum: e.currentTarget.dataset.index
    })

  },
  delImg(e){
    let source = this.data.source
    source.splice(e.currentTarget.dataset.index,1)
    this.setData({
      source: source
    })
    if (source.length != 3){
      this.setData({
        block: true
      })
    }
  },
  uploadimg: function() {
    let that = this
    wx.chooseImage({
      count: 1,
      sizeType: ['compressed'], //可以指定原图还是压缩图，默认二者都有
      sourceType: ['album', 'camera'],//可以指定来源相册还是相机，默认二者都有

      success(res) {

        let arr = that.data.source
        console.log(res.tempFilePaths, arr, arr.length,123123)
        arr.push(res.tempFilePaths[0])
        that.setData({
          source: arr
        })
        if (that.data.source.length == 3 ){
          that.setData({
            block: false
          })
        }
      }
    })
  },
  getVal(e) {
    let val = e.detail.value
    this.setData({
      describe: val
    })
  }
})